﻿// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Reflection;
using Microsoft.Internal;

namespace System.ComponentModel.Composition.ReflectionModel
{
    internal abstract class ReflectionComposablePartDefinition : ComposablePartDefinition, ICompositionElement
    {
        private readonly ICompositionElement _origin;

        protected ReflectionComposablePartDefinition(ICompositionElement origin)
        {
            this._origin = origin;
        }

        public abstract ConstructorInfo Constructor
        {
            get;
        }

        public abstract Type PartType
        {
            get;
        }

        string ICompositionElement.DisplayName
        {
            get { return GetDisplayName(); }
        }

        ICompositionElement ICompositionElement.Origin
        {
            get { return this._origin; }
        }

        public override string ToString()
        {
            return GetDisplayName();
        }

        private string GetDisplayName()
        {
            return this.PartType.GetDisplayName();
        }
    }
}
